layui.config({
    base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
    index: 'lib/index' //主入口模块
}).use(['index', 'form'], function(){
    var $ = layui.$,
        form = layui.form,
        element = layui.element;

    var payData;
    var userId = $('#userId').val();
    post('user/toEditPayConfig', {'userId': userId}, false,function (data) {
        payData = data.pay;

        renderer();
    });

    function renderer(){
        if(payData == null || payData == undefined){
            return;
        }

        var payWay = $('#payWay input:checked').val();
        if(payWay == 1){    //支付宝
            if(payData.aliPayType == 0){
                form.val("layuiadmin-form-data", {
                    type: 0
                });
            }else{
                form.val("layuiadmin-form-data", {
                    type: 1
                });
            }
        }else{
            if(payData.wxPayType == 0){
                form.val("layuiadmin-form-data", {
                    type: 0
                });
            }else{
                form.val("layuiadmin-form-data", {
                    type: 1
                });
            }
        }
    }

    form.on('radio(payWay)', function(data){
        renderer();
    });

});